#include <iostream>
#include <string>

std::string dfs(std::string const & s, int pos)
{
	int l = s.size();
	if (pos == l) return "";
	int p; char ch = 'a' - 1;
	for (int i = pos; i < l; i++)
		if (s[i] > ch) {
			ch = s[i];
			p = i;
		}
	std::string t = dfs(s, p + 1);
	return ch + (t[0] == ch ? t : "");
}

int main()
{
	std::string s;
	std::cin >> s;
	std::cout << dfs(s, 0) << '\n';
}

